!function ($) {
    var wxopenid=$.cookie('wxopenid');
    // var wxopenid='123456';
    // $.cookie('wxopenid', wxopenid, { expires: 1});
    if (wxopenid==''||wxopenid==null){
        var access_code=$.getUrlParam('code');
        var state=$.getUrlParam('state');
        if (access_code==null){
            var url='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx901f02bac5476a60&redirect_uri='+encodeURIComponent(link)+'&response_type=code&scope=snsapi_base&state=rossedu%23wechat_redirect&connect_redirect=1#wechat_redirect';
            location.href=url;
        } else {
            $.ajax({
                type:'get',
                url:ctxPath + "/wx/api/openid",
                async:false,
                data:{code:access_code,state:state},
                success:function(result){
                    if (result!=''){
                        $.cookie('wxopenid', result, { expires: 1});
                    } else{
                        alert('微信身份识别失败 \n ');
                        // location.href=link;
                    }
                },
                error:function (result) {
                    console.log("result: " + result);
                }
            });
        }
    }
}(jQuery);